<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<base href="http://localhost/shopex/" />
<link rel="stylesheet" type="text/css" href="App/Admin/Common/images/metinfo.css" />
<script type="text/javascript" src="App/Admin/Common/ckeditor/ckeditor.js"></script>
<link rel="stylesheet" href="App/Admin/Common/css/common.css">
   <link rel="stylesheet" href="App/Admin/Common/css/newslist.css">
   
   <script type="text/javascript" src="App/Admin/Common/js/jquery.min.js"></script>
   <script type="text/javascript" src="App/Admin/Common/js/colResizable-1.3.min.js"></script>
   <script type="text/javascript" src="App/Admin/Common/js/common.js"></script>
   
   <script type="text/javascript">
      $(function(){  
        $(".list_table").colResizable({
          liveDrag:true,
          gripInnerHtml:"<div class='grip'></div>", 
          draggingClass:"dragging", 
          minWidth:30
        }); 
        
      }); 
   </script>
   
<script src="resource/js/jQuery1.7.2.js"></script>

<script>
/*$(document).ready(function(e) {	
	$("#id").live('change',function(){
		var checked=$(this).attr("checked");
		if(checked=="checked"){			
			$(".check").attr("checked",true);			
			}else{
				$(".check").attr("checked",false);
				}				
		});	    
});*/

$(document).ready(function(e) {	
	$(".checkall").live('click',function(){		
		$(".check").attr("checked",true);					
	});	    
});

$(document).ready(function(e) {	
	$(".cancela").live('click',function(){		
		$(".check").attr("checked",false);					
	});	    
});

//点击改变状态
$(document).ready(function(e) {
    
	//新品状态改变
	$("#new").live('click',function(){	
		var statusid=$(this).attr('name');
		var id=$(this).attr('class');
		$.ajax({
			
			type:"POST",
			url:"index.php/admin/goods/clickajax",
			data:{
				statusid:statusid,
				id:id,
				type:'new'
				},
			dataType:"json",
			success: function(json){
				var strimg='';
				if(json){
					if(statusid==1){
						strimg+='<img id="new" name="0" class="'+id+'" src="App/Admin/Common/images/not_0.png" />';
					}else{
						
						strimg+='<img id="new" name="1" class="'+id+'" src="App/Admin/Common/images/not_1.png" />';	
					}
					$('.new'+id).html(strimg);	
				}else{
					alert('修改失败');
				}	
			}			
		});
	});
	
	
	
	//热销状态改变
	$("#hot").live('click',function(){	
		var statusid=$(this).attr('name');
		var id=$(this).attr('class');
		$.ajax({
			
			type:"POST",
			url:"index.php/admin/goods/clickajax",
			data:{
				statusid:statusid,
				id:id,
				type:'hot'
				},
			dataType:"json",
			success: function(json){
				var strimg='';
				if(json){
					if(statusid==1){
						strimg+='<img id="hot" name="0" class="'+id+'" src="App/Admin/Common/images/not_0.png" />';
					}else{
						
						strimg+='<img id="hot" name="1" class="'+id+'" src="App/Admin/Common/images/not_1.png" />';	
					}
					$('.hot'+id).html(strimg);	
				}else{
					alert('修改失败');
				}	
			}			
		});
	});
	
	
	
	//推荐状态改变recommend
	$("#recommend").live('click',function(){	
		var statusid=$(this).attr('name');
		var id=$(this).attr('class');
		$.ajax({
			
			type:"POST",
			url:"index.php/admin/goods/clickajax",
			data:{
				statusid:statusid,
				id:id,
				type:'recommend'
				},
			dataType:"json",
			success: function(json){
				var strimg='';
				if(json){
					if(statusid==1){
						strimg+='<img id="recommend" name="0" class="'+id+'" src="App/Admin/Common/images/not_0.png" />';
					}else{
						
						strimg+='<img id="recommend" name="1" class="'+id+'" src="App/Admin/Common/images/not_1.png" />';	
					}
					$('.recommend'+id).html(strimg);	
				}else{
					alert('修改失败');
				}	
			}			
		});
	});
	
	
	//上下架状态改变
	$("#frame").live('click',function(){	
		var statusid=$(this).attr('name');
		var id=$(this).attr('class');
		$.ajax({
			
			type:"POST",
			url:"index.php/admin/goods/clickajax",
			data:{
				statusid:statusid,
				id:id,
				type:'frame'
				},
			dataType:"json",
			success: function(json){
				var strimg='';
				if(json){
					if(statusid==1){
						strimg+='<img id="frame" name="0" class="'+id+'" src="App/Admin/Common/images/checky_0.png"" />';
					}else{
						
						strimg+='<img id="frame" name="1" class="'+id+'" src="App/Admin/Common/images/checky_1.png" />';	
					}
					$('.frame'+id).html(strimg);	
				}else{
					alert('修改失败');
				}	
			}			
		});
	});
	
	
	
	
	//sort排序快捷修改
	$(".sort").dblclick(function(){
		var val=$(this).text();
		var input='<input type="text" style="border:#CCC solid 1px;"  size="5">';
		$(this).html(input);
		$(this).find("input").val(val);
		 //$("#sort input").val(val);
	});
	
	$(".sort input").live("blur",function(){
		
		var id=$(this).parent().attr('name');
		
		var sort1=$(this).val();
	
		$(this).parent().html(sort1);
		
		$.ajax({
			type:"POST",
			url:"index.php/admin/goods/shortcutajax",
			data:{
				sort1:sort1,
				id:id,
				type:'sort'
				},
			dataType:"json",
			success: function(json){
				//alert(json);
			}	
			
			
		});
	
	});
	
	
	
	
	
});


</script>   

</head>

<body>

	<div class="metinfotop">
	<div class="position">简体中文：商品管理 > <a href="index.php/admin/goods/list">商品列表</a></div>

	</div>
	<div class="clear"></div>


<div class="stat_list">
	<ul>
		<li <?php if($now == 1 ): ?>class="now"<?php endif; ?> ><a href="index.php/admin/goods/list/status/1" title="新闻列表">商品列表</a></li>
		<li <?php if($now == 2 ): ?>class="now"<?php endif; ?> ><a href="index.php/admin/goods/list/status/2" title="商品回收站">商品回收站</a></li>
	</ul>
</div>
      <div id="search_bar" class="mt10">
       <div class="box">
          <div class="box_border">
            <div class="box_top"><b class="pl15">搜索</b></div>
            <div class="box_center pt10 pb10">
            <form action="" method="get">
              <table class="form_table" border="0" cellpadding="0" cellspacing="0">
              
                <tr>
                  <td>关键字</td>
                  <td><input type="text" name="keyword" class="input-text lh25" size="50"></td>
                  
                  <!--分类-->
                  <!--<td>分类</td>-->
                  <td>
                    <span class="fl">
                      <div class="select_border"> 
                        <div class="select_containers "> 
                        <select name="catid" class="select">
                        	<option value="0">所有分类</option> 
                            <?php if(is_array($clist)): foreach($clist as $key=>$vo): ?><option value="<?php echo ($vo["catid"]); ?>"><?php echo ($vo["name"]); ?></option><?php endforeach; endif; ?>
                        </select> 
                        </div> 
                      </div> 
                    </span>
                  </td>
                  
                  
                  <!--品牌-->
                  <!--<td>品牌</td>-->
                  <td>
                    <span class="fl">
                      <div class="select_border"> 
                        <div class="select_containers "> 
                        <select name="bid" class="select">
                        	<option value="0">所有品牌</option> 
                            <?php if(is_array($blist)): foreach($blist as $key=>$vo): ?><option value="<?php echo ($vo["bid"]); ?>"><?php echo ($vo["name"]); ?></option><?php endforeach; endif; ?>
                        </select> 
                        </div> 
                      </div> 
                    </span>
                  </td>
                  
                  
                 <td>
                    <span class="fl">
                      <div class="select_border"> 
                        <div class="select_containers "> 
                        <select name="tjian" class="select">
                        	<option value="-1">全部</option>  
                            <option value="0">新品</option> 
                            <option value="1">热销</option> 
                            <option value="2">推荐</option> 
                        </select> 
                        </div> 
                      </div> 
                    </span>
                  </td>
                  
                  
                  <!--<td>状态</td>-->
                  <td>
                    <span class="fl">
                      <div class="select_border"> 
                        <div class="select_containers "> 
                        <select name="frame" class="select">
                        	<option value="-1">全部</option>  
                            <option value="1">上架</option> 
                            <option value="0">下架</option> 
                        </select> 
                        </div> 
                      </div> 
                    </span>
                  </td>
                  
                  
                  
                  <td><input type="submit" value="确定" class="ext_btn ext_btn_submit"></td>
                </tr>
               
              </table>
              </form>
            </div>
       
          </div>
        </div>
    </div>

<div id="table" class="mt10">
        <div class="box span10 oh">
        <form action="index.php/admin/goods/batchdel" method="post">
              <table width="100%" border="0" cellpadding="0" cellspacing="0" class="list_table">
                <tr>
                   <th width="100"><!--<input  id="id" type="checkbox"  >-->ID</th>
                   <th>商品名称</th>
                   <th width="120">商品编号</th>
                   <th width="100">价格</th>
                   <th width="35">新品</th>
                   <th width="35">热销</th>
                   <th width="35">推荐</th>
                   <th width="80">库存</th>
                   <th width="60">排序</th>
                   <th width="90">上架时间</th>
                   <th width="60">上/下架</th>
                   <th width="100">操作</th>
                </tr>
                
                <tbody id="list">
                <?php if(is_array($list)): foreach($list as $k=>$vo): ?><tr class="tr">
                       <td class="td_center"><input type="checkbox" name="id[]" class="check" id="nid"  value="<?php echo ($vo["id"]); ?>" ><?php echo ($vo["id"]); ?></td>
                       <td align="center"><?php echo ($vo["title"]); ?></td>
                       <td align="center"><?php echo ($vo["number"]); ?></td>
                       <td align="center"><?php echo ($vo["price"]); ?></td>
                       <td align="center" class="new<?php echo ($vo["id"]); ?>"><img id="new" name="<?php echo ($vo["new"]); ?>" class="<?php echo ($vo["id"]); ?>" src="App/Admin/Common/images/not_<?php echo ($vo["new"]); ?>.png" /></td>
                       <td align="center" class="hot<?php echo ($vo["id"]); ?>"><img id="hot" name="<?php echo ($vo["hot"]); ?>" class="<?php echo ($vo["id"]); ?>" src="App/Admin/Common/images/not_<?php echo ($vo["hot"]); ?>.png" /></td>
                       <td align="center" class="recommend<?php echo ($vo["id"]); ?>"><img id="recommend" name="<?php echo ($vo["recommend"]); ?>" class="<?php echo ($vo["id"]); ?>" src="App/Admin/Common/images/not_<?php echo ($vo["recommend"]); ?>.png" /></td>
                       <td align="center"><?php echo ($vo["count"]); ?></td>
                       <td align="center" class="sort" name="<?php echo ($vo["id"]); ?>"><?php echo ($vo["sort"]); ?></td>
                       <td align="center"><?php echo (date("Y-m-d",$vo["addtime"])); ?></td>
					   <td align="center" class="frame<?php echo ($vo["id"]); ?>"><img id="frame" name="<?php echo ($vo["frame"]); ?>" class="<?php echo ($vo["id"]); ?>" src="App/Admin/Common/images/checky_<?php echo ($vo["frame"]); ?>.png" /></td>

                       <td align="center">
                           <?php if($vo["status"] == 2 ): ?><a href="index.php/admin/goods/return/id/<?php echo ($vo["id"]); ?>" onclick="return confirm('你确实要把该商品还原?')">还原</a>
                                 &nbsp;&nbsp;
                                <a href="index.php/admin/goods/del/id/<?php echo ($vo["id"]); ?>" onclick="return confirm('你确实要把该记录删除?')">删除</a>
                           <?php else: ?>
                               <a href="index.php/admin/goods/recycle/id/<?php echo ($vo["id"]); ?>" onclick="return confirm('你确实要把该商品放入回收站?')">
                               <img src="App/Admin/Common/images/dele.png" alt="放入回收站" />
                               </a>&nbsp;&nbsp;<a href="index.php/admin/goods/save/id/<?php echo ($vo["id"]); ?>" onclick="return confirm('你确实要把该记录修改?')">
                               <img src="App/Admin/Common/images/enid.png" alt="编辑" /></a></td><?php endif; ?>
                      </td>    
                  </tr><?php endforeach; endif; ?>
                </tbody>
                
                
              	<tr>
                   <th colspan="11" align="left">
                       <input type="button" name="button" class="btn btn82 btn_checked checkall" value="全选"> 
       					<input type="button" name="button" class="btn btn82 btn_nochecked cancela" value="取消">  
                   		<input type="submit" name="del" class="btn btn82 btn_del" value="删除"> 
                        <input type="submit" name="status1" class="btn btn82 btn_del" value="上架"> 
                        <input type="submit" name="status0" class="btn btn82 btn_del" value="下架"> 
  
                   </th>
                </tr>
                
              </table>
              </form>
              <div class="page mt10">
                <div class="pagination">
                <ul><?php echo ($page); ?></ul>              
                </div>

              </div>
        </div>
     </div>

</body>
</html>